Subscribe Us

Responsive Advertisement

Advertisement

1539B love song codeforces solution in cpp

 1539B love song codeforces solution in cpp

by ujjal roy


#include<bits/stdc++.h>

using namespace std;

main()

{


  int n,q,r,l,i;

  long long int sum=0;

  cin>>n>>q;

  string s;

  vector<long long int > v(n+1);


  cin>>s;

  v[0]=0;

  for(i=1;i<=n;i++)

  {

       int r=s[i-1]+1-'a';


          v[i]=v[i-1]+r;

  }

  while(q--)

  {


      cin>>l>>r;


      cout<<v[r]-v[l-1]<<endl;

  }



    return 0;

}








Post a Comment

0 Comments